package com.hmall.order.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: cuiliangbo
 * @Date: 2022/6/16 22:02
 */
@SuppressWarnings("all")
@Configuration
public class RabbitMQConfig {


    @Bean
    public Queue OrderQueue(){

        return QueueBuilder.durable("order.queue")   //指定队列名称并持久化
                .deadLetterExchange("dl.ttl.exchange")   //指定死信交换机
                .deadLetterRoutingKey("dl")
                .build();
    }

    @Bean
    public TopicExchange orderExchange(){

        return new  TopicExchange("order.topic");
    }

    @Bean
    public Binding bingQueue(){
        return BindingBuilder.bind(OrderQueue())
                .to(orderExchange())
                .with("order.create");
    }

}
